package org.example.spring;

import org.springframework.util.StopWatch;

import java.util.concurrent.TimeUnit;

/**
 * User: ZhangJuntao
 * Date: 13-11-19
 * Time: 下午10:23
 */
public class StopWatchTest {
  public static void main(String[] args) throws InterruptedException {
    StopWatch sw = new StopWatch();
    sw.start("hans");
    TimeUnit.SECONDS.sleep(1);
    sw.stop();
    System.out.println(sw.getLastTaskName() + " cost " + sw.getLastTaskTimeMillis());
    sw.start("zjt");
    TimeUnit.SECONDS.sleep(2);
    sw.stop();
    System.out.println(sw.getLastTaskName() + " cost " + sw.getLastTaskTimeMillis());
    System.out.println("total cost " + sw.getTotalTimeMillis());
  }
}
